$(function () {
  var topbar = $('.header-bar-container');

  //fixed navigation bar to top --PC

  if (topbar.is('*')) {

    var elem = $('.jumbotron');

    var offset = elem.offset();

    var leftValue = offset.left;

    var topValue = offset.top + 100;

    var width = elem.width();

    var topbarHeight = topbar.height();

    var stickyDiv = '<div class="sticky-placeholder" style="height:' + topbarHeight + 'px"></div>';

    $(window).scroll(function (event) {

      var y = $(this).scrollTop();

      if (y >= topValue) {

        if (topbar.hasClass('fixed')) {

        } else {

          topbar.addClass('fixed').addClass('sticky');

          $('#page header').prepend(stickyDiv);

          topbar.css({

            top: '-' + topbarHeight + 'px',

            width: '100%'

          });

          topbar.animate({

            top: '0'

          }, 500, function () {

          });

        }

      } else {

        if (topbar.hasClass('sticky')) {

          topbar.removeClass('sticky');

          topbar.animate({

            top: '-' + topbarHeight + 'px'

          }, 100, function () {

            $('.sticky-placeholder').remove();

            topbar.removeClass('fixed');

          });

          //topbar.fadeOut('fast', function () {

          //  topbar.fadeIn('fast');

          //});

        }

      }

    });

  }

});